package cn.tedu.mall.front.service.impl;

import cn.tedu.mall.common.exception.CoolSharkServiceException;
import cn.tedu.mall.common.restful.ResponseCode;
import cn.tedu.mall.front.mappers.FrontSpuDetailMapper;
import cn.tedu.mall.front.service.IFrontSpuDetailService;
import cn.tedu.mall.pojo.product.vo.SpuDetailStandardVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
@DubboService
public class FrontSpuDetailServiceImpl implements IFrontSpuDetailService {

    private final FrontSpuDetailMapper frontSpuDetailMapper;

    @Autowired
    public FrontSpuDetailServiceImpl(FrontSpuDetailMapper frontSpuDetailMapper) {
        this.frontSpuDetailMapper = frontSpuDetailMapper;
    }


    @Override
    public SpuDetailStandardVO getSpuDetail(Long spuId) {
        SpuDetailStandardVO spuDetailStandardVO = frontSpuDetailMapper.selectSpuDetailBySpuId(spuId);
        if (spuDetailStandardVO == null) {
            throw new CoolSharkServiceException(ResponseCode.NOT_FOUND, "此spuId没有对应spu详情！");
        }
        return spuDetailStandardVO;
    }
}
